<template>
  <div class="NewHuman">
    <!-- <div class="center-header">
      <div class="comeplay">
        <span>欢迎来到XXX主持人团队！ 客服：13812341234</span>
      </div>
      <div class="loginRegister">
        <button class="login">登录</button>
        <button class="register">注册</button>
      </div>
    </div> -->
    <Head />
    <div class="logo">
      <img src="../../../assets/logo.png" alt="" />
    </div>
    <div class="NewHumanTab">
      <el-tabs type="border-card">
        <el-tab-pane label="我的预订">
          <Scheduled />
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="NewHuman-a">
      <el-button type="text" @click="updateNewHandle">个人资料</el-button>
      <el-dialog
        title="个人资料"
        :visible.sync="dialogVisible"
        width="30%"
        :before-close="handleClose"
      >
        <el-form
          :model="ruleForm"
          status-icon
          ref="ruleForm"
          label-width="100px"
          class="demo-ruleForm"
        >
          <el-form-item label="姓名" prop="pass"
            >{{ weddingName }}
          </el-form-item>
          <el-form-item label="手机号" prop="phone">
            <el-input type="text" v-model="ruleForm.phone"></el-input>
          </el-form-item>
          <el-form-item label="邮箱" prop="email">
            <el-input type="text" v-model="ruleForm.email"></el-input>
          </el-form-item>
          <el-form-item label="密码" prop="password">
            <el-input type="password" v-model="ruleForm.password"></el-input>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogVisible = false">取 消</el-button>
          <el-button type="primary" @click="sureHandle">确 定</el-button>
        </span>
      </el-dialog>
    </div>
    <Footer />
  </div>
</template>

<script>
import Head from "../../../components/Head";
import Scheduled from "./Scheduled";
import Footer from "../../../components/Footer";
import api from "../../../api";
export default {
  name: "NewcomerPage",
  data() {
    return {
      dialogVisible: false,
      weddingName: localStorage.getItem("wedding-user"),
      ruleForm: {
        phone: "",
        email: "",
        password: "",
      },
    };
  },
  components: {
    Head,
    Scheduled,
    Footer,
  },
  methods: {
    handleClose() {
      this.dialogVisible = false;
    },
    updateNewHandle() {
      this.dialogVisible = true;
    },
    sureHandle() {
      api
        .updateNew({
          pname: this.weddingName,
          pphone: this.ruleForm.phone,
          pmail: this.ruleForm.email,
          ppwd: this.ruleForm.password,
        })
        .then((res) => {
          this.$message.success(res.data.msg);
          this.dialogVisible = false;
        });
    },
    preUpdate(name) {
      api
        .preUpdateNew({
          pname: name,
        })
        .then((res) => {
          console.log(res.data);
          if (res.status == 200) {
            this.ruleForm.phone = res.data.result[0].pphone;
            this.ruleForm.email = res.data.result[0].pmail;
            this.ruleForm.password = res.data.result[0].ppwd;
          }
        });
    },
  },
  mounted() {
    this.preUpdate(this.weddingName);
  },
};
</script>

<style scpoed lang="less">
.NewHuman {
  position: relative;
  width: 100%;
}
.PaginationBox {
  margin-top: 30px;
  bottom: 0px;
}
.NewHuman-a {
  position: absolute;
  left: 110px;
  top: 205px;
}
.logo {
  margin-left: 100px;
  margin-top: 20px;
  margin-bottom: 60px;
  width: 210px;
  height: 80px;
}
.loginRegister {
  position: absolute;
  top: 5px;
  right: 10px;
  margin-right: 50px;
}
.center-header {
  position: relative;
  width: 100%;
  height: 60px;
  line-height: 60px;
  background-color: darkgrey;
}
.midLand {
  margin-left: 50px;
}
.titleText {
  margin-left: 160px;
  font-size: 20px;
}
.AddDayHeaderImg {
  margin-left: 10px;
  margin-top: 20px;
  width: 90px;
  height: 50px;
  background-color: aquamarine;
}
.AddDayMid-a {
  font-size: 16px;
  margin-left: 50px;
  margin-top: 20px;
}
.AddDayMid-a-inp {
  margin-left: 20px;
}
.AddDayMid-a-inp-t {
  margin-left: 70px;
}
.tishi {
  color: red;
  font-size: 12px;
}
</style>